
import RxRequest from "./platform/request/RxRequest_VITE_APP_PLATFORM.js";
import RxElement from "./utils/RxElement.js";

import RxTab from "./ui/components/RxTab.js";
import RxLoading from "./ui/components/RxLoading.js";
import RxDialog from "./ui/components/RxDialog.js";

document.addEventListener('DOMContentLoaded', () => {
  getCacheConfigFn();
  RxTab()


  // ---- dialog ----
  // setTimeout(() => {
  //   RxDialog.show()
  //   setTimeout(() => {
  //     RxDialog.hidden()
  //   }, 5000);
  // }, 2000);

  // ---- load ----
  // setTimeout(() => {
  //   RxLoading.show()
  //   setTimeout(() => {
  //     RxLoading.hidden()
  //   }, 5000);
  // }, 2000);
})

function getCacheConfigFn() {
  console.log('init')
  // console.log('app env=', __APP_ENV__)
  console.log('meta env=', import.meta.env)
  console.log('RxRequest=', RxRequest)
  RxRequest.getLocalCache().then(res => {
    console.log('cache res=', res)
  }).catch(error => {
    console.error(error)
  })


  RxElement.getElButtonIdFun('cancel', () => {
    console.log('cancel')
    RxRequest.cancel()
  })

  RxElement.getElButtonIdFun('confirm', () => {
    console.log('confirm')
    RxRequest.confirm()
  })
}

// <模板> 加入 <ui>
function _set_c() {
  const tempId = RxElement.getElButtonId('tab_0_muilte')
  const tempIdNode = tempId.content.cloneNode(tempId)
  const tabContentId = RxElement.getElButtonId('tab_content')
  // console.log('tabContentId=', tabContentId)
  tabContentId.appendChild(tempIdNode)
}
